package com.tsd.core.utils;

import java.util.HashMap;
import java.util.Map;

/**
 * @author Hillpool
 */
public class Transform {
    private static final Map<String, String> TRANSFORM_MAP;

    static {
        TRANSFORM_MAP = new HashMap<>();
        TRANSFORM_MAP.put("char", "String");
        TRANSFORM_MAP.put("varchar", "String");
        TRANSFORM_MAP.put("longvarchar", "String");
        TRANSFORM_MAP.put("numeric", "BigDecimal");
        TRANSFORM_MAP.put("decimal", "BigDecimal");
        TRANSFORM_MAP.put("bit", "Boolean");
        TRANSFORM_MAP.put("int", "Integer");
        TRANSFORM_MAP.put("tinyint", "Integer");
        TRANSFORM_MAP.put("smallint", "Integer");
        TRANSFORM_MAP.put("mediumint", "Integer");
        TRANSFORM_MAP.put("integer", "Integer");
        TRANSFORM_MAP.put("bigint", "Long");
        TRANSFORM_MAP.put("real", "Float");
        TRANSFORM_MAP.put("float", "Double");
        TRANSFORM_MAP.put("double", "Double");
        TRANSFORM_MAP.put("binary", "Byte[]");
        TRANSFORM_MAP.put("varbinary", "Byte[]");
        TRANSFORM_MAP.put("longvarbinary", "Byte[]");
        TRANSFORM_MAP.put("date", "Date");
        TRANSFORM_MAP.put("datetime", "Date");
        TRANSFORM_MAP.put("time", "Time");
        TRANSFORM_MAP.put("timestamp", "Timestamp");
        TRANSFORM_MAP.put("clob", "Clob");
        TRANSFORM_MAP.put("blob", "Blob");
        TRANSFORM_MAP.put("text", "String");
    }

    public static String getJavaType(String jdbcType) {
        return TRANSFORM_MAP.get(jdbcType.toLowerCase());
    }
}
